package logic

import (
	"context"
	"fmt"
	"good_srv/model/mysql"
	"strconv"

	"good_srv/good"
	"good_srv/internal/svc"

	"github.com/zeromicro/go-zero/core/logx"
)

type UserNoLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewUserNoLogic(ctx context.Context, svcCtx *svc.ServiceContext) *UserNoLogic {
	return &UserNoLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

func (l *UserNoLogic) UserNo(in *good.UserNoRequest) (*good.UserNoResponse, error) {
	// todo: add your logic here and delete this line
	var user mysql.User
	err := user.FindUser(strconv.FormatInt(in.UserId, 10))
	if err != nil {
		return nil, fmt.Errorf("该用户不存在")
	}
	user.Status = "冻结"
	err = user.Update()
	if err != nil {
		return nil, fmt.Errorf("冻结失败")
	}
	return &good.UserNoResponse{}, nil
}
